package cn.com.taiji.pos.service.impl;

import cn.com.taiji.pos.entity.CardInfo;
import cn.com.taiji.pos.mapper.CardInfoMapper;
import cn.com.taiji.pos.service.ICardInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.dreamyoung.mprelation.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 卡片信息 服务实现类
 * </p>
 *
 * @author
 * @since 2021-03-01
 */
@Service
public class CardInfoServiceImpl extends ServiceImpl<CardInfoMapper, CardInfo> implements ICardInfoService {
    @Autowired
    private CardInfoMapper cardInfoMapper;

    @Override
    public CardInfo findByCardCode(String cardCode) {
        QueryWrapper<CardInfo> cardInfoWrapper = new QueryWrapper<>();
        cardInfoWrapper.eq("STATUS", 0);
        cardInfoWrapper.eq("CARD_CODE", cardCode);
        return cardInfoMapper.selectOne(cardInfoWrapper);
    }

    @Override
    public boolean linkCard(String cardCode, String cardId) {
        if (cardInfoMapper.linkCard(cardCode, cardId) == 1) {
            return true;
        } else {
            return false;
        }

    }
}
